<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>背景图片大小</title>
    <style>
        .box1{
            width: 300px;
            height: 300px;
            background-image: url(img/1.png);
            background-repeat: no-repeat;
            background-color: yellow;
            /**
                1. 300px 300px
                2. 100% 100%
                3. cover  等比例缩放填满空间 会存在裁剪
                4. contain  等比例缩放填满空间 不会存在裁剪 存在流白
            **/
            background-size: contain;
        }
    </style>
</head>
<body>
    <div class="box1"></div>
</body>
</html>